home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_xemacs.idb / usr / freeware / lib / xemacs-20.4 / lisp / ilisp / ilisp-dia.el.z / ilisp-dia.el
Encoding:
Text File  |  1998-05-21  |  7.1 KB  |  206 lines

  1. ;;; -*- Mode: Emacs-Lisp -*-
  2.  
  3. ;;; ilisp-dia.el --
  4.  
  5. ;;; This file is part of ILISP.
  6. ;;; Version: 5.8
  7. ;;;
  8. ;;; Copyright (C) 1990, 1991, 1992, 1993 Chris McConnell
  9. ;;;               1993, 1994 Ivan Vasquez
  10. ;;;               1994, 1995, 1996 Marco Antoniotti and Rick Busdiecker
  11. ;;;               1996 Marco Antoniotti and Rick Campbell
  12. ;;;
  13. ;;; Other authors' names for which this Copyright notice also holds
  14. ;;; may appear later in this file.
  15. ;;;
  16. ;;; Send mail to 'ilisp-request@naggum.no' to be included in the
  17. ;;; ILISP mailing list. 'ilisp@naggum.no' is the general ILISP
  18. ;;; mailing list were bugs and improvements are discussed.
  19. ;;;
  20. ;;; ILISP is freely redistributable under the terms found in the file
  21. ;;; COPYING.
  22.  
  23.  
  24. ;;;%%CUSTOMIZING DIALECTS
  25. ;;;
  26. ;;; ILISP is already set up with support for a number of dialects.
  27. ;;; Each dialect has a command NAME that will start an inferior LISP
  28. ;;; of that dialect.  NAME-hook is a hook that will run after the
  29. ;;; default settings for NAME are set up.  NAME-program is the default
  30. ;;; program for NAME. A prefix when starting a dialect will cause you
  31. ;;; to be prompted for the buffer name and the program.  When setting
  32. ;;; something in a hook, you should use the most general dialect that
  33. ;;; makes sense. Dialect definitions and their hooks are executed from
  34. ;;; least specific to most specific.  They will be executed before the
  35. ;;; inferior LISP is started.
  36. ;;;
  37. ;;; These are the currently supported dialects.  The dialects
  38. ;;; are listed so that the indentation correponds to the hierarchical
  39. ;;; relationship between dialects.
  40. ;;; clisp
  41. ;;;   allegro
  42. ;;;   Clisp     (Haible and Stoll)
  43. ;;;   lispworks (Harlequin)
  44. ;;;   lucid
  45. ;;;   cmulisp
  46. ;;;   kcl
  47. ;;;     akcl
  48. ;;;     ibcl
  49. ;;;     ecl
  50. ;;;     gcl
  51. ;;; scheme
  52. ;;;   oaklisp
  53. ;;;   Scheme->C (still "in fieri")
  54. ;;;
  55. ;;; If anyone figures out support for other dialects I would be happy
  56. ;;; to include it in future releases.
  57. ;;;
  58. ;;; ;;; Example of local changes and extensions to ilisp mode
  59. ;;; (setq ilisp-load-hook
  60. ;;;       '(lambda ()
  61. ;;;         ;; Change the allegro lisp program
  62. ;;;         (setq allegro-program "/usr/misc/bin/lisp")
  63. ;;;         ;; Add a new key binding
  64. ;;;         (defkey-ilisp "\C-\M-a" 'arglist-lisp)
  65. ;;;         ;; Define a new subdialect to run on another machine.
  66. ;;;         (defdialect cmlisp "Connection Machine LISP."
  67. ;;;           lucid
  68. ;;;           (setq ilisp-program
  69. ;;;            "rsh power /usr/local/cm/bin/starlisp"))))
  70. ;;;
  71. ;;; ;;; Automatically load a new subdialect
  72. ;;; (autoload 'cmlisp "ilisp" "Run an inferior CM lisp." t)
  73. ;;;
  74. ;;; To define a new dialect use the macro defdialect.  For examples,
  75. ;;; look at the dialect definitions in this file.  There are hooks and
  76. ;;; variables for almost anything that you are likely to need to
  77. ;;; change.  The relationship between dialects is hierarchical with
  78. ;;; the root values being defined in setup-ilisp.  For a new dialect,
  79. ;;; you only need to change the variables that are different than in
  80. ;;; the parent dialect.
  81.  
  82.  
  83. ;;;
  84. ;;; ILISP dialect definition code.
  85. ;;;
  86.  
  87. ;;;%Dialects
  88. (defun lisp-add-dialect (dialect)
  89.   "Add DIALECT as a supported ILISP dialect."
  90.   (if (not (lisp-memk dialect ilisp-dialects 'car))
  91.       (setq ilisp-dialects
  92.         (cons (list dialect) ilisp-dialects))))
  93.  
  94. ;;;
  95. (defun ilisp-start-dialect (buffer program setup)
  96.   ;; Allow dialects to be started from command line
  97.   (if (eq current-prefix-arg 0) (setq current-prefix-arg nil))
  98.   (setq ilisp-last-buffer (current-buffer)
  99.     buffer (if current-prefix-arg
  100.            (read-from-minibuffer "Buffer: " buffer)
  101.            buffer))
  102.   (funcall setup buffer)
  103.   (setq ilisp-program
  104.     (or program 
  105.         (if current-prefix-arg
  106.         (lisp-read-program "Program: " ilisp-program)
  107.         ilisp-program)))
  108.   (ilisp buffer setup))
  109.  
  110. ;;;
  111. (defmacro defdialect (dialect full-name parent &rest body)
  112.   "Define a new ILISP dialect.  DIALECT is the name of the function to
  113. invoke the inferior LISP. The hook for that LISP will be called
  114. DIALECT-hook.  The default program will be DIALECT-program.  FULL-NAME
  115. is a string that describes the inferior LISP.  PARENT is the name of
  116. the parent dialect."
  117.   (let ((setup (read (format "setup-%s" dialect)))
  118.     (hook (read (format "%s-hook" dialect)))
  119.     (program (read (format "%s-program" dialect)))
  120.     (dialects (format "%s" dialect)))
  121.     (`
  122.      (progn
  123.        (defvar (, hook) nil (, (format "*Inferior %s hook." full-name)))
  124.        (defvar (, program) nil
  125.      (, (format "*Inferior %s default program." full-name)))
  126.        (defun (, setup) (buffer)
  127.      (, (format "Set up for interacting with %s." full-name))
  128.      (, (read (format "(setup-%s buffer)" parent)))
  129.      (,@ body)
  130.      (setq ilisp-program (or (, program) ilisp-program)
  131.            ilisp-dialect (cons '(, dialect) ilisp-dialect))
  132.      (run-hooks '(, (read (format "%s-hook" dialect)))))
  133.        (defun (, dialect) (&optional buffer program)
  134.      (, (format "Create an inferior %s.  With prefix, prompt for buffer and program."
  135.            full-name))
  136.      (interactive (list nil nil))
  137.      (ilisp-start-dialect (or buffer (, dialects)) 
  138.                   program 
  139.                   '(, setup))
  140.      (setq (, program) ilisp-program))
  141.        (lisp-add-dialect (, dialects))))))
  142.  
  143. ;;;%%ilisp
  144. (defun setup-ilisp (buffer)
  145.   "Set up for interacting with an inferior LISP."
  146.   (set-buffer (get-buffer-create "*ilisp-send*"))
  147.   (kill-all-local-variables)
  148.   (lisp-mode)
  149.   (setq ilisp-buffer (format "*%s*" buffer))
  150.   (set-buffer (get-buffer-create ilisp-buffer))
  151.   (setq major-mode 'ilisp-mode
  152.     mode-name "ILISP")
  153.   (lisp-mode-variables t)
  154.   ;; Set variables to nil
  155.   (let ((binary ilisp-binary-extension)
  156.     (init ilisp-init-binary-extension)
  157.     (vars ilisp-locals))
  158.     (while (not (null vars))
  159.       (make-local-variable (car vars))
  160.       (set (car vars) nil)
  161.       (setq vars (cdr vars)))
  162.     ;; Preserve from initialization
  163.     (if binary (setq ilisp-binary-extension binary))
  164.     (if init (setq ilisp-init-binary-extension init)))
  165.   ;; Comint defaults
  166.   (set-ilisp-input-ring-size 200)
  167.   (setq comint-prompt-regexp "^[^<> ]*>+:? *"
  168.  
  169.     comint-get-old-input 'ilisp-get-old-input
  170.     comint-input-sentinel (function ignore)
  171.     comint-input-filter 'ilisp-input-filter
  172.     comint-input-sender 'comint-default-send
  173.     comint-eol-on-send t)
  174.   ;; Comint-ipc defaults
  175.   (setq comint-send-newline t
  176.     comint-always-scroll nil
  177.     comint-output-buffer " *Output*"
  178.     comint-error-buffer " *Error Output*"
  179.     comint-error-regexp "^\"ILISP:"
  180.     comint-output-filter (function identity)
  181.     comint-interrupt-start 'comint-interrupt-start
  182.     comint-handler 'ilisp-handler
  183.     comint-update-status 'ilisp-update-status
  184.     comint-prompt-status 'comint-prompt-status
  185.     comint-abort-hook 'ilisp-abort-handler)
  186.   (setq ilisp-use-map ilisp-mode-map
  187.     ilisp-init-hook '((lambda () (ilisp-init nil nil t)))
  188.     ilisp-filter-regexp "\\`\\s *\\(:\\(\\w\\|\\s_\\)*\\)?\\s *\\'"
  189.     ilisp-filter-length 3
  190.     ilisp-error-filter 'ilisp-error-filter
  191.     ilisp-error-regexp ".*" 
  192.     ilisp-symbol-delimiters "^ \t\n\('\"#.\)<>"
  193.     ilisp-program "lisp"
  194.     ilisp-locator 'lisp-locate-ilisp
  195.     ilisp-calls-locator 'lisp-locate-calls)
  196.   (run-hooks 'ilisp-mode-hook))
  197.  
  198. (defun run-ilisp ()
  199.   "Create an inferior LISP prompting for dialect.  With prefix, prompt
  200. for buffer name as well."
  201.   (interactive)
  202.   (let ((dialect (completing-read "Dialect: " ilisp-dialects nil t)))
  203.     (if (not (zerop (length dialect)))
  204.     (call-interactively (read dialect)))))
  205.  
  206.